import { _colors } from "../color/index.js"
import { plainMatrix } from "../math/index.js"
import { gridCellPoints } from "../algorithm/grid.js"
import { _polygon } from "./polygon.js"
import { _g } from "./svg.js"


export const _gridPolygon = (options, props) => {
    let { r = 25, a = 0, n, transform, grid, color = "colorCircle" } = options

    let gcps = plainMatrix(gridCellPoints({
        r: 50,
        ...grid
    }))

    let colors = _colors(color, gcps.length, 0.5)
    let children = gcps.map((t, i) => {
        return _polygon({
            o: t,
            n,
            r, a,
            transform
        }, {
            fill: colors[i],//   'red',
            stroke: 'none',
            ...props
        })

    })
    return _g(children)

}


export const _gridRect = (options, props) => {
    return _gridPolygon({
        ...options,
        n: 4
    }, props)
}